<template>
    <div class="newsInfor-container"> 
     
      <h1  class="title">新闻标题{{newsInfo.title}}</h1>
      <p class="subtitle">
          <span>发表时间:{{newsInfo.add_time  }}</span>
          <span>点击:{{newsInfo.click}}次</span>
      </p>
      <hr>
      <div class="content" v-html="newsInfo.content"></div>
      <!-- 评论区域 -->
      <comment-box :id="id"></comment-box>
    </div>
</template>
<script>
import Toast from 'mint-ui'
import comment from '../subcomponents/comment.vue'
export default {
    data(){
        return {
            id: this.$route.params.id,
            newsInfo:{}
        }

    },
    created(){
        this.getNewsInfo()
    },
    methods:{
        getNewsInfo(){
            this.$http.get('api/getnew/'+this.id).then(result=>{
                if(result.body.status===0){
                    this.newsInfo=result.body.messages[0]
                }else{
                    Toast('请求失败')
                }
            })
        }
    },
    components:
       {'comment-box':comment}
    
    
}
</script>
<style lang="scss" >
    .newsInfor-container {
        padding: 0 10px;
        .title {
            font-size: 16px;
            color: red;
             text-align: center;
            margin: 15px 0;
         }
         .subtitle{
             display: flex;
             justify-content: space-between;
             font-size: 12px;
             color: #226aff;
         }
         .content {
             img {
                 height: 100%;
                 width: 100px;
             }
         }
    }
   
</style>